package com.lc.sell.controller;


import com.lc.sell.entity.Addresses;
import com.lc.sell.service.AddressesService;
import com.lc.sell.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙晨
 * @since 2022-02-01
 */
@Api(tags = "地址控制")
@RestController
@RequestMapping("addresses")
public class AddressesController {

    @Autowired
    private AddressesService addressesService;

    @ApiOperation(value = "添加用户地址")
    @PostMapping("add")
    public ResultVo address(@RequestBody Addresses addresses,@RequestParam String userid){
        return addressesService.insertAddresses(addresses,userid);
    }

    @ApiOperation(value = "修改用户地址")
    @PostMapping("upd")
    public ResultVo updAddress(@RequestBody Addresses addresses){
        return addressesService.updateAddresses(addresses);
    }

    @ApiOperation(value = "查询地址列表")
    @GetMapping("addresses")
    public ResultVo addList(@RequestParam String userid){
        return addressesService.selectAddressList(userid);
    }

    @ApiOperation(value = "删除地址信息")
    @GetMapping("del")
    public ResultVo deleteAdd(@RequestParam Integer id){
       return addressesService.deleteAddresses(id);
    }

    @ApiOperation(value = "查询地址信息")
    @GetMapping("sel")
    public ResultVo selectOneAddresses(@RequestParam Integer id){
        return addressesService.selectOneAddresses(id);
    }
}
